package com.yibo.redis.util.lock;

import com.yibo.support.helper.Assert;

/**
 * 获取锁
 */
public final class LockUtil {

    private static final String  LOCK_KEY_NULL = "lock key not null";

    private LockUtil(){}

    public static RedisLock  getLock(String lockKey){
        Assert.notEmpty(LOCK_KEY_NULL,lockKey);
        return new RedisLock(lockKey);
    }

    public static RedisLock  getLock(String lockKey,LockBack lockBack){
        Assert.notEmpty(LOCK_KEY_NULL,lockKey);
        return new RedisLock(lockKey,lockBack);
    }


    public static RedisLock  getLock(String lockKey,int expire){
        Assert.notEmpty(LOCK_KEY_NULL,lockKey);
        return new RedisLock(lockKey,expire);
    }

    public static RedisLock getLock(String lockKey,int expire,LockBack lockBack){
        Assert.notEmpty(LOCK_KEY_NULL,lockKey);
        return new RedisLock(lockKey,expire,lockBack);
    }
}
